<?php


if (!defined('BASEPATH'))
    exit('No direct script access allowed'); //seguridad bloqueo de carpetas


class Dashboard extends CI_Controller {
    
    function __construct() {
        parent::__construct();
    //    $this->_is_logued_in();
        $this->load->library('table');
         $this->load->model('Users_Model');
         $this->load->helper('form');
        $this->load->library('form_validation');
    }


    function index(){
        
        $data['title'] = 'Dashboard';
        $data['main_content'] = 'dashboard/index';
        $this->load->view('includes/template', $data);
        
    }
    
    function verify_login() {               //verificar login
       
        
        
        $usernamel = $this->input->post('usernamelogin');
        $passwordl = md5($this->input->post('passwordlogin'));
        $login = $this->Users_Model->verify_login($usernamel,$passwordl);
      
           
       
           
       
            $data = array(
                'is_logued_in' => TRUE,
                'nombre_usuario' => $login[0]->username,
                'name' => $login[0]->name,
                'user_id' => $login[0]->id,
                'mail' =>$login[0] ->email   
                 ); 
             
            $this->session->set_userdata($data);
            redirect('dashboard');
      
        
    }
//    function _is_logued_in(){
//      
//        $is_logued_in = $this->session->userdata('is_logued_in');
//      $user_id = $this->session->userdata('user_id');
//        if ($is_logued_in != true OR $user_id == '') {
//    
//            redirect('users/login');
//            
//        }
//    }
    
}
?>
